package dcutils.graphs;

/**
 * The abstract base-class for both weighted and unweighted graphs.<br/>
 * Contains fields and methods which are common to both kinds of graphs.<br/>
 * @author dca
 */
public abstract class Graph<V> {
   /**
    * A flag which, if true, edges wont be added in both directions between vertices.<br/>
    * If false, edges will be added in both directions.
    */
   protected boolean directed;

   /**
    * Returns directed.<br/>
    * @return directed
    */
   public boolean isDirected() {
      return directed;
   } // END isDirected

   /**
    * Adds a vertex to the graph.<br />
    * This vertex will not currently have edges going to or from it.
    * @param vertex The vertex to add to the graph.
    */
   public abstract void addVertex(V vertex);

   /**
    * Checks if a vertex is within the graph.
    * @param vertex The vertex to check.
    * @return true or false.
    */
   public abstract boolean hasVertex(V vertex);

   /**
    * Returns an array of vertices from within the graph, no edges.
    * @return String A string array of vertices.
    */
   public abstract String verticesToString();

   /**
    * Returns the list of edges for a given vertex, as a string.
    * @param vertex The vertex from which the edges must begin.
    * @return String A string array of edges, preceded by the vertex.
    */
   public abstract String edgesToString(V vertex);

   /**
    * Returns all vertices and edges in the entire graph.
    * @return String A string array of vertices and their edges.
    */
   public abstract String graphToString();

   /**
    * Clears out the graph.
    */
   public abstract void clearGraph();
} // END class Graph
